import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'

const request: AxiosInstance = axios.create({
    baseURL: import.meta.env.VITE_BASE_API as string,
    timeout: 10000,
    headers: {
        'Token': '123456789'
    }
})

request.interceptors.request.use(
    (config: InternalAxiosRequestConfig) => {
        return config
    },
    function (error: any) {
        return Promise.reject(error)
    }
)

request.interceptors.response.use(
    (response: AxiosResponse) => {
        return response
    },
    function (error: any) {
        return Promise.reject(error)
    }
)

export default request